local skill = fk.CreateSkill {
  name = "ling__stolen_horse_skill",
}

Fk:loadTranslationTable{
  ["#ling__stolen_horse-use"] = "穆公盗马：是否令 %src 视为使用【酒】？",
}

skill:addEffect("cardskill", {
  prompt = "#ling__stolen_horse_skill",
  target_num = 1,
  mod_target_filter = function(self, player, to_select, selected, card, extra_data)
    return to_select ~= player and
      #to_select:getEquipments(Card.SubtypeDefensiveRide) + #to_select:getEquipments(Card.SubtypeOffensiveRide) > 0
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local player = effect.from
    local target = effect.to
    if player.dead or target.dead then return end
    local cards = table.connect(target:getEquipments(Card.SubtypeDefensiveRide), target:getEquipments(Card.SubtypeOffensiveRide))
    if #cards == 0 then return end
    local card = room:askToChooseCard(player, {
      target = target,
      flag = { card_data = {{ target.general, cards }} },
      skill_name = skill.name,
    })
    room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, skill.name, nil, true, player)
    if player.dead or target.dead then return end
    if player:canUseTo(Fk:cloneCard("ling__analeptic"), player, { bypass_times = true }) and
      room:askToSkillInvoke(target, {
        skill_name = skill.name,
        prompt = "#ling__stolen_horse-use:"..player.id,
      }) then
      room:useVirtualCard("ling__analeptic", nil, player, player, skill.name, true)
    end
  end,
})

skill:addAI(nil, "__card_skill")
skill:addAI(nil, "default_card_skill")

return skill
